import type { ChatMessage } from "@/types";
import axios, { AxiosError } from "axios";
import request from "./request"


export async function chat(input: String) {
  try {
    const completion = await axios({
      url: "http://127.0.0.1:8183/ivy/task/changeToSql",
      method: "post",
      data: JSON.stringify({
        input
      })
    });
    console.log(completion)
    return completion
  } catch (error: any) {
    return {
      status: "error",
      message: error.response.data.error.message,
    };
  }
}

export async function chatSql(input: String) {
  return request({
    url: '/ivy/task/changeToSql',
    method: 'post',
    data: {
      input
    }

  })
}
